<?php

/**
 * Current conditions entity
 *
 * @copyright  Copyright (c) 2011 Celebrio Software
 * @package    WeatherApi
 */
namespace Celebrio\WeatherApi\WorldWeatherOnline;

use Celebrio\WeatherApi\WorldWeatherOnline\WeatherConditions;
use Celebrio\Util\DateParser;

class ForecastConditions extends WeatherConditions {
    private $date;
    private $dayOfWeek;
    private $dateParsed;
    private $tempMaxC;
    private $tempMaxF;
    private $tempMinC;
    private $tempMinF;
    private $tempAverageC;
    private $tempAverageF;
    private $winddirection;
    
    public function getDate() {
        return $this->date;
    }

    public function setDate($date) {
        $this->date = DateParser::get_date($date);
        $this->setDayOfWeek($date);
    }
    
    public function getDayOfWeek() {
        return $this->dayOfWeek;
    }

    public function setDayOfWeek($date) {
        $day = DateParser::getDayOfWeek($date, true);
        $this->dayOfWeek = $day;
    }

        
    public function getDateParsed() {
        return $this->dateParsed;
    }

    public function setDateParsed($date) {
        $parsed = \explode("-", $date);
        $parsedDate = array(
            "year" => $parsed[0],
            "month" => $parsed[1],
            "day" => $parsed[2]
        );
        $this->dateParsed = $parsedDate;
    }
    
    
    public function getTempMaxC() {
        return $this->tempMaxC;
    }

    public function setTempMaxC($tempMaxC) {
        $this->tempMaxC = $tempMaxC;
    }

    public function getTempMaxF() {
        return $this->tempMaxF;
    }

    public function setTempMaxF($tempMaxF) {
        $this->tempMaxF = $tempMaxF;
    }

    public function getTempMinC() {
        return $this->tempMinC;
    }

    public function setTempMinC($tempMinC) {
        $this->tempMinC = $tempMinC;
    }

    public function getTempMinF() {
        return $this->tempMinF;
    }

    public function setTempMinF($tempMinF) {
        $this->tempMinF = $tempMinF;
    }

    public function getWinddirection() {
        return $this->winddirection;
    }

    public function setWinddirection($winddirection) {
        $this->winddirection = $winddirection;
    }
    
    public function getTempAverageC() {
        return $this->tempAverageC;
    }

    public function getTempAverageF() {
        return $this->tempAverageF;
    }

        
    public function setAverageTemps() {
        $this->tempAverageC = $this->calculateAverageTemps(
                $this->getTempMinC(), 
                $this->getTempMaxC());
        $this->tempAverageF = $this->calculateAverageTemps(
                $this->getTempMinF(), 
                $this->getTempMaxF());
    }
    
    private function calculateAverageTemps($tempLow, $tempHigh) {
        return (int) round(($tempHigh + $tempLow)/2);
    }

    
}